<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace AlibabaCloud\Client\Credentials\Providers;

class RamRoleArnProvider extends Provider
{
    public function get($timeout = \AlibabaCloud\Client\Request\Request::TIMEOUT, $connectTimeout = \AlibabaCloud\Client\Request\Request::CONNECT_TIMEOUT)
    {
        $credential = $this->getCredentialsInCache();
        if(NULL === $credential) {
            $result = $this->request($timeout, $connectTimeout);
            if(!(isset($result["Credentials"]["AccessKeyId"]) && isset($result["Credentials"]["AccessKeySecret"]) && isset($result["Credentials"]["SecurityToken"]))) {
                throw new \AlibabaCloud\Client\Exception\ServerException($result, $this->error, \AlibabaCloud\Client\SDK::INVALID_CREDENTIAL);
            }
            $credential = $result["Credentials"];
            $this->cache($credential);
        }
        return new \AlibabaCloud\Client\Credentials\StsCredential($credential["AccessKeyId"], $credential["AccessKeySecret"], $credential["SecurityToken"]);
    }
    private function request($timeout, $connectTimeout)
    {
        $clientName = "AlibabaCloud\\Client\\Credentials\\Providers\\RamRoleArnProvider" . uniqid("ak", true);
        $credential = $this->client->getCredential();
        \AlibabaCloud\Client\AlibabaCloud::accessKeyClient($credential->getAccessKeyId(), $credential->getAccessKeySecret())->name($clientName);
        return (new \AlibabaCloud\Client\Credentials\Requests\AssumeRole($credential))->client($clientName)->timeout($timeout)->connectTimeout($connectTimeout)->debug($this->client->isDebug())->request();
    }
}

?>